import time
import streamlit as st
st.title('智能小助手')
st.text('这是一个智能小助手，可以对你的任何问题进行解答！请尽情的使用吧')
message = st.chat_input('请输入你的问题')

def ai_response():
    my_message = " seconds between each word to simulate the chatbot before responding. Finally, we append the chatbot's response to the chat history. "
    for word in my_message.split():
        yield word+" "
        time.sleep(0.5)

if message:
    with st.chat_message("user"):
        st.write(message)
    # AI回复一下
    with st.chat_message('assistant'):
        st.write('我是AI助手')
    with st.chat_message('assistant'):
        st.write('我是AI助手')
        res = ai_response()
        st.write_stream(res)